#include "IndexBuffer.h"

IndexBuffer::IndexBuffer(const unsigned int *data, unsigned int count, GLenum usage):m_count(count)
{
	static_assert(sizeof(unsigned int)==sizeof(GLuint));

	glGenBuffers(1,&m_id);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,m_id);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER,m_count*sizeof(unsigned int),data,usage);
}

void IndexBuffer::bind() const
{
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,m_id);
}

void IndexBuffer::unbind() const
{
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,0);
}

IndexBuffer::~IndexBuffer()
{
	glDeleteBuffers(1,&m_id);
}


